package com.ruoyi.buss.grid.dqcd.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.grid.dqcd.domain.QmcyCustDqcd;
import com.ruoyi.buss.grid.dqcd.service.IQmcyCustDqcdService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 定期存单Controller
 * 
 * @author zjh
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/qmcyCustDqcd")
public class QmcyCustDqcdController extends BaseController
{
    @Autowired
    private IQmcyCustDqcdService qmcyCustDqcdService;

    /**
     * 查询定期存单列表
     */
    @PreAuthorize(hasPermi = "buss:qmcyCustDqcd:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyCustDqcd qmcyCustDqcd)
    {
        startPage();
        List<QmcyCustDqcd> list = qmcyCustDqcdService.selectQmcyCustDqcdList(qmcyCustDqcd);
        return getDataTable(list);
    }

    /**
         * 导出定期存单列表
     */
    @PreAuthorize(hasPermi = "buss:qmcyCustDqcd:export")
    @Log(title = "定期存单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyCustDqcd qmcyCustDqcd) throws IOException
    {
        List<QmcyCustDqcd> list = qmcyCustDqcdService.selectQmcyCustDqcdList(qmcyCustDqcd);
        ExcelUtil<QmcyCustDqcd> util = new ExcelUtil<QmcyCustDqcd>(QmcyCustDqcd.class);
        util.exportExcel(response, list, "定期存单数据");
    }

    /**
     * 获取定期存单详细信息
     */
    @PreAuthorize(hasPermi = "buss:qmcyCustDqcd:query")
    @GetMapping(value = "/{tdTdAcctNo}")
    public AjaxResult getInfo(@PathVariable("tdTdAcctNo") String tdTdAcctNo)
    {
        return AjaxResult.success(qmcyCustDqcdService.selectQmcyCustDqcdById(tdTdAcctNo));
    }

    /**
     * 新增定期存单
     */
    @PreAuthorize(hasPermi = "buss:qmcyCustDqcd:add")
    @Log(title = "定期存单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyCustDqcd qmcyCustDqcd)
    {
        return toAjax(qmcyCustDqcdService.insertQmcyCustDqcd(qmcyCustDqcd));
    }

    /**
     * 修改定期存单
     */
    @PreAuthorize(hasPermi = "buss:qmcyCustDqcd:edit")
    @Log(title = "定期存单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyCustDqcd qmcyCustDqcd)
    {
        return toAjax(qmcyCustDqcdService.updateQmcyCustDqcd(qmcyCustDqcd));
    }

    /**
     * 删除定期存单
     */
    @PreAuthorize(hasPermi = "buss:qmcyCustDqcd:remove")
    @Log(title = "定期存单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tdTdAcctNos}")
    public AjaxResult remove(@PathVariable String[] tdTdAcctNos)
    {
        return toAjax(qmcyCustDqcdService.deleteQmcyCustDqcdByIds(tdTdAcctNos));
    }
}
